import request from '@/api/request'
import axios from 'axios'
import qs from 'qs'
const VUE_APP_BASE_API_5G="https://online5g.bigchun.com/"
// const VUE_APP_BASE_API_5G="https://xingwu.bigchun.com/"
// const VUE_APP_BASE_API_5G="http://shop.com/"
const front_http="https://xingwufront.bigchun.com/"
const weixinapp_http = 'https://xctong.bigchun.com/'
const IMGUrl='https://oss.bigchun.com/'
const base_name="醒悟大健康"
//  const VUE_APP_BASE_API_5G = "https://yggs.bigchun.com/"
const http = {

    /**
     * method:请求
     * @params url 请求地址
     * @params params 请求参数
     * */
    //列表+详情
    get(url, params) {
        const config = {
            method: 'get',
            url: VUE_APP_BASE_API_5G + url
        }
        if (params) config.params = params
        return request(config)


    },
    // 请求微信api
    post2(url, params) {
        const config = {
            method: 'post',
            url: weixinapp_http + url,
        }
        if (params) config.data = qs.stringify(params)
        console.log(config);
        return request(config)
    },
    //新增
    post(url, params) {
        if(params && params.weixinApi){
            const config = {
                method: 'post',
                url: weixinapp_http + url,
            }
            if (params) config.data = qs.stringify(params)
            console.log(config);
            return request(config)
        }
        const config = {
            method: 'post',
            url: VUE_APP_BASE_API_5G + url,
        }
        if (params) config.data = qs.stringify(params)
        console.log(config);
        return request(config)
    },
    //上传图片
    postImages(url, params) {
        const config = {
            method: 'post',
            url: VUE_APP_BASE_API_5G + url,
            headers: {
                'content-type': 'multipart/form-data',
            },
        }
        if (params) config.data = params
        return request(config)

    },
    post_t(url, params) {
        let token = weixin.getToken()
        return axios({
            headers: {
                'content-type': 'application/json;charset=utf-8',
                'Authorization': '' + token
            },
            url: VUE_APP_BASE_API_5G + url,
            method: 'post',
            data: params
        })
    },
    //修改
    put(url, params) {
        const config = {
            method: 'put',
            url: VUE_APP_BASE_API_5G + url
        }
        if (params) config.data = qs.stringify(params)
        return request(config)
    },

}

export default {
    http,
    base_name,
    front_http,
    VUE_APP_BASE_API_5G,
    IMGUrl
}
